package com.tyj.movie.controller;


import com.tyj.movie.entity.MovieTheatre;

import com.tyj.movie.service.MovieTheatreServerService;
import com.tyj.movie.service.MovieTheatreService;
import com.tyj.movie.vo.CinemasDetailShowVo;
import com.tyj.movie.vo.CinemasVo;
import com.tyj.movie.vo.MovieTheatreServerVo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;


import java.text.ParseException;
import java.util.List;
import java.util.concurrent.ExecutionException;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author tyj
 * @since 2021-06-28
 */
@RestController
@RequestMapping("/movie/theatre")
public class MovieTheatreController {

    @Autowired
    MovieTheatreService movieTheatreService;

    @Autowired
    MovieTheatreServerService movieTheatreServerService;
    /**
     * 影院页
     */
    @RequestMapping("/cinemas")
    public ModelAndView cinemas() throws ExecutionException, InterruptedException {
        ModelAndView modelAndView = new ModelAndView();
        CinemasVo cinemasVo = movieTheatreService.queryMovieTheatreVo();
        modelAndView.addObject("cinemasVo",cinemasVo);
        modelAndView.setViewName("cinemas");
        return modelAndView;
    }

    /**
     * 影院详情
     */
    @RequestMapping("/cinemaDetail/{movieTheatreId}")
    public ModelAndView movieTheatreDetail(@PathVariable("movieTheatreId") Long movieTheatreId) throws ParseException {
        ModelAndView modelAndView=new ModelAndView();

        //影院详情
        MovieTheatre movieTheatre = movieTheatreService.queryMovieTheatreAndBrand(movieTheatreId);
        modelAndView.addObject("movieTheatre",movieTheatre);

        //影院服务
        List<MovieTheatreServerVo> movieTheatreServerVoList=movieTheatreServerService.queryMovieTheatreServerVoList(movieTheatreId);
        modelAndView.addObject("movieTheatreServerVoList",movieTheatreServerVoList);

        //电影放映
        List<CinemasDetailShowVo> cinemasDetailShowVos=movieTheatreService.queryCinemasDetailShowVo(movieTheatreId);
        modelAndView.addObject("cinemasDetailShowVos",cinemasDetailShowVos);

        //查询座位


        modelAndView.setViewName("cinemadatas");
        return modelAndView;
    }

}

